<?php

namespace common\modules\pms\models\backend;

/**
 * Class Project
 *
 * @property mixed taskGanttConfig
 * @package common\modules\pms\models\backend
 */
class Project extends \common\modules\pms\models\Project
{

    /**
     * @const string
     */
    const PASS_PROJECT_PARAM = 'pass_project_to_node';

    /**
     * @return array
     */
    public function getTaskGanttConfig()
    {
        $source = [];
        $sourceModels = TaskTree::getTreeObjects('　', ['project_id' => $this->id]);
        if (is_array($sourceModels) && ! empty($sourceModels))
        {
            /** @var TaskTree $sourceModel */
            foreach ($sourceModels as $name => $sourceModel)
            {
                $source[] = [
                    'name' => $name,
                    //'desc' => $sourceModel->name,
                    'values' => [
                        [
                            'from' => "/Date({$sourceModel->start_time}000)/",
                            'to' => "/Date({$sourceModel->end_time}000)/",
                            'label' => $sourceModel->description ? $sourceModel->description : $sourceModel->name,
                            'customClass' => $sourceModel->getColorClass(),
                        ],
                    ],
                ];
            }
        }

        return $source;
    }
}
